cmake_minimum_required(VERSION 3.8)
project(node_pkg)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msg_pkg REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(rclcpp_action REQUIRED)

add_executable(helloword src/helloword.cpp)
ament_target_dependencies(helloword rclcpp)

add_executable(template_node src/template_node.cpp)
ament_target_dependencies(template_node rclcpp)
# template_lifecycle_node
add_executable(template_lifecycle_node src/template_lifecycle_node.cpp)
ament_target_dependencies(template_lifecycle_node "rclcpp" "rclcpp_lifecycle")

add_executable(topic_publisher src/topic_publisher.cpp)
ament_target_dependencies(topic_publisher rclcpp std_msgs)

add_executable(topic_subscriber src/topic_subscriber.cpp)
ament_target_dependencies(topic_subscriber rclcpp std_msgs)
# click_listener
add_executable(click_listener src/click_listener.cpp)
ament_target_dependencies(click_listener rclcpp geometry_msgs)
# test_node
add_executable(test_node src/test_node.cpp)
ament_target_dependencies(test_node "rclcpp" "geometry_msgs" "nav_msg_pkg")
# param_listener
add_executable(param_listener src/param_listener.cpp)
ament_target_dependencies(param_listener "rclcpp" "rcl_interfaces" )

# 自定义msg消息使用
add_executable(demo_msg_node src/msg/demo_msg_node.cpp)
ament_target_dependencies(demo_msg_node "rclcpp" "geometry_msgs" "nav_msg_pkg")
# 自定义srv服务使用
add_executable(demo_srv_server src/srv/demo_srv_server.cpp)
ament_target_dependencies(demo_srv_server "rclcpp"  "nav_msg_pkg")
add_executable(demo_srv_client src/srv/demo_srv_client.cpp)
ament_target_dependencies(demo_srv_client "rclcpp"  "nav_msg_pkg")
# action_server
add_executable(demo_action_server src/action/demo_action_server.cpp)
ament_target_dependencies(demo_action_server "rclcpp" "nav_msg_pkg" "rclcpp_action" )
# action_client
add_executable(demo_action_client src/action/demo_action_client.cpp)
ament_target_dependencies(demo_action_client "rclcpp" "nav_msg_pkg" "rclcpp_action" )
# 参数服务
add_executable(demo_param src/param/demo_param.cpp)
ament_target_dependencies(demo_param "rclcpp" )
add_executable(demo_param_server src/param/demo_param_server.cpp)
ament_target_dependencies(demo_param_server "rclcpp"  )
add_executable(demo_param_client src/param/demo_param_client.cpp)
ament_target_dependencies(demo_param_client "rclcpp")

# 安装规则
install(TARGETS
  helloword
  template_node
  template_lifecycle_node
  topic_publisher
  topic_subscriber
  click_listener
  test_node
  param_listener
  demo_srv_server
  demo_srv_client
  demo_action_server
  demo_action_client
  demo_msg_node
  demo_param
  demo_param_server
  demo_param_client
  DESTINATION lib/${PROJECT_NAME})

install(
    DIRECTORY
     launch
    DESTINATION
     share/${PROJECT_NAME}
    )

    
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
